/**
 * 6074. 字母在字符串中的百分比
 * https://leetcode.cn/contest/weekly-contest-294/problems/percentage-of-letter-in-string/
 */

/**
 * @param {string} s
 * @param {string} letter
 * @return {number}
 */
function percentageLetter(s, letter) {
  let count = 0;
  for (let i = 0; i < s.length; i += 1) {
    if (s[i] === letter) {
      count += 1;
    }
  }
  return Math.floor((count / s.length) * 100);
}

console.log(percentageLetter('foobar', 'o') === 33);
console.log(percentageLetter('jjjj', 'k') === 0);
